package com.bckj.fastboot.iot.biz.service.impl;

import com.alibaba.cola.statemachine.StateMachineFactory;
import com.bckj.fastboot.iot.common.dto.ctx.IotDeviceContext;
import com.bckj.fastboot.iot.common.enums.IotDeviceEvent;
import com.bckj.fastboot.iot.common.enums.IotDeviceState;
import com.bckj.fastboot.iot.common.enums.IotFsmIdEnum;
import com.bckj.fastboot.iot.biz.service.IotDeviceFireEventService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * DeviceStateMachine
 *
 * @author wfc
 **/
@Slf4j
@Service
@RequiredArgsConstructor
public class IotDeviceFireEventServiceImpl implements IotDeviceFireEventService {

    /**
     * 触发状态机
     *
     * @param state 当前状态
     * @param event 事件
     * @param ctx 上下文
     */
    @Override
    public void fire(IotDeviceState state, IotDeviceEvent event, IotDeviceContext ctx) {
        StateMachineFactory.get(IotFsmIdEnum.DEVICE_STATE_MACHINE.getId())
                .fireEvent(state, event, ctx);
    }
}
